package com.cr.mrapp.service.impl;

import com.cr.mrapp.dao.ItemDao;
import com.cr.mrapp.entity.Item;
import com.cr.mrapp.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


//服务项目的功能实现类
@Service
public class ItemServiceImpl implements ItemService {

    @Autowired   //可以从Spring容器中诸如一个实例
    private ItemDao itemDao;

    @Override
    public Item findById(int itemId ) {

        return itemDao.selectByPrimaryKey(itemId);
    }

    @Override
    public int addItem(Item body) {
        return itemDao.insert(body);
    }

    @Override
    public List<Object> findByPage(int page, int limit, String itemType) {
        return itemDao.selectByPage((page-1)*limit,limit, itemType);
    }

    @Override
    public int findCount() {
        return itemDao.selectCount();
    }

    @Override
    public int deleteById(int itemId) {
        return itemDao.deleteByPrimaryKey(itemId);
    }
}